import { BaseWindow } from "../../../component/window/BaseWindow";
import { ILayer } from "../../../mvc/interfaces/ILayer";
import { Language } from "../../../../extend/language/Language";
import { MuiEvent } from "../../../../com/mui/events/MuiEvent";
import { DataProvider } from "../../../../fl/data/DataProvider";
import { SRobIslandFightPetList } from "../../../../Message/Game/SRobIslandFightPetList";
import { ObjCreate } from "../common/ObjCreate";
import { GTabBar } from "../../../../com/mui/controls/GTabBar";
import { FilterConst } from "../../../component/gconst/FilterConst";
import { GlobalStyle } from "../../../common/global/GlobalStyle";
import { ScrollPolicy } from "../../../../fl/controls/ScrollPolicy";
import { PetIslandFightListItemRenderer } from "./renderer/PetIslandFightListItemRenderer";
import { GTileList } from "../../../../com/mui/controls/GTileList";
import { GTextFiled } from "../../../../com/mui/controls/GTextFiled";
//class PetIslandFightListPanel
    
    export  class PetIslandFightListPanel extends BaseWindow
    {
        constructor(arg1: ILayer=null)
        {
            super(arg1);
            setSize(226, 300);
            titleHeight = 26;
            title = Language.getString(28230);
            return;
        }

        /* internal  */onTabBarSelectedChange(arg1: MuiEvent=null): void
        {
            if (this._vo) 
            {
                if (this._tabBar.selectedIndex != 0) 
                {
                    this._list.dataProvider = new DataProvider(this._vo.defensePets);
                    this._petNum.text = Language.getStringByParam(28221, this._vo.defensePets.length);
                }
                else 
                {
                    this._list.dataProvider = new DataProvider(this._vo.attackPets);
                    this._petNum.text = Language.getStringByParam(28221, this._vo.attackPets.length);
                }
                this._list.drawNow();
            }
            return;
        }

        public set data(arg1: SRobIslandFightPetList)
        {
            this._vo = arg1 as SRobIslandFightPetList;
            this._vo.attackPets.sortOn("maxLife", Array.NUMERIC | Array.DESCENDING);
            this._vo.defensePets.sortOn("maxLife", Array.NUMERIC | Array.DESCENDING);
            this._tabBar.selectedIndex = 0;
            this.onTabBarSelectedChange();
            return;
        }

        protected /* override */ createChildren(): void
        {
            super.createChildren();
            ObjCreate.createBg(18, 61, 190, 228, this);
            this._tabBar = new GTabBar();
            this._tabBar.x = 25;
            this._tabBar.y = 38;
            this._tabBar.horizontalGap = 2;
            this._tabBar.buttonWidth = 60;
            this._tabBar.buttonFilters = [FilterConst.glowFilter];
            this._tabBar.selectedIndex = 0;
            this._tabBar.dataProvider = Language.getArray(28218);
            this._tabBar.addEventListener(MuiEvent.GTABBAR_SELECTED_CHANGE, this.onTabBarSelectedChange);
            this.addChild(this._tabBar);
            ObjCreate.createGTextField(Language.getString(28174), 40, 65, 40, 20, this);
            ObjCreate.createGTextField(Language.getString(28220), 133, 65, 40, 20, this);
            this._petNum = ObjCreate.createGTextField("", 150, 40, 60, 20, this, GlobalStyle._textFormat5);
            this._list = ObjCreate.createTileList(24, 88, 180, 200, this);
            this._list.verticalScrollPolicy = ScrollPolicy.AUTO;
            this._list.columnWidth = 180;
            this._list.rowHeight = 30;
            this._list.setStyle("cellRenderer", PetIslandFightListItemRenderer);
            return;
        }

        /* internal */ /* var */_tabBar: GTabBar;

        /* internal */ /* var */_list: GTileList;

        /* internal */ /* var */_petNum: GTextFiled;

        /* internal */ /* var */_vo: SRobIslandFightPetList;
    }
